<div class="panel panel-default panel-intro">
    {:build_heading()}
    <style>
        table thead th{
            text-align: center;
        }
        table tbody tr td{
            text-align: center;
            width: 10%;
        }
        table tbody tr td .date_time{
            display: block;
        }
        table tbody tr td .date_price{
            display: block;
            color: orange;
            width: 80%;
            border: none;
            margin: 0px auto;
            text-align: center;
            font-weight: bold;
            height: 28px;
            line-height: 28px;
        }
        input::-webkit-outer-spin-button,
        input::-webkit-inner-spin-button {
            -webkit-appearance: none;
        }
        input[type="number"]{
            -moz-appearance: textfield;
        }
        .date_title{
            width: 20%;
            height: 36px;
            margin: 0px auto;
            text-align: center;
            font-size: 16px;
        }
        .date_click{
            cursor: pointer;
        }
    </style>
    <script charset="utf-8" src="/assets/libs/jquery/dist/jquery.min.js"></script>
    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div class="date_title">
                        <a href="{$ids}/date/{$last_date}"><img class="date_click left_arrow" data-date="{$date}" data-type="1" src="/assets/img/left.png" alt="" width="20" height="20"></a>
                        <span>{$date}</span>
                        <a href="{$ids}/date/{$next_date}"><img class="date_click right_arrow" data-date="{$date}" data-type="2" src="/assets/img/right.png" alt=""width="20" height="20"></a>
                    </div>
                    <input type="hidden" name="ids" id="merchant_car_id" value="{$ids}">
                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap" width="100%">
                        <thead>
                            {foreach $week as $vo}
                            <th>{$vo}</th>
                            {/foreach}
                        </thead>
                        <tbody>
                            {volist name="list" id="ve"}
                            <tr>
                                {volist name="ve" id="vv"}
                                {if !empty($vv)}
                                <td>
                                    <span class="date_time">{$vv.date}</span>
                                    {if $vv.is_edit==0}
                                    <span style="color: red" class="date_price" data-edit="{$vv.is_edit}" data-id="{$vv.price_id}" data-price="{$vv.price}">{$vv.price}</span>
                                    {else/}
<!--                                    <span class="date_price" data-edit="{$vv.is_edit}" data-id="{$vv.price_id}">{$vv.price}</span>-->
                                    <input type="number" class="date_price" data-edit="{$vv.is_edit}" data-id="{$vv.price_id}" data-price="{$vv.price}" value="{$vv.price}" data-date="{$date}-{$vv.date}">
                                    {/if}
                                </td>
                                {else/}
                                <td>
                                    <span class="date_time"></span>
                                    <span class="date_price" data-edit="0" data-id="0"></span>
                                </td>
                                {/if}
                                {/volist}
                            </tr>
                            {/volist}

                        </tbody>
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>
<script>
   $(".date_price").blur(function () {
       var price_id = $(this).attr('data-id');
       var old_price = $(this).attr('data-price');
       var price = $(this).val();
       var merchant_car_id = $("#merchant_car_id").val();
       var date = $(this).attr('data-date');
       if(price != old_price){
           Fast.api.ajax({
               url:'merchant_car/far_price_add',
               data:{price:price,merchant_car_id:merchant_car_id,date:date}
           },function (data,ret) {
               console.log(ret);
               parent.Toastr.success("更新成功！");//成功后提示
               $(".btn-refresh").trigger("click");
               location.reload();
               return false;
           },function (data,ret) {
               parent.Toastr.error(ret.msg);
               return false;
           });
       }
   })
</script>
